<!DOCTYPE html>
<script src='../../../resources/testharness.js'></script>
<script src='../../../resources/testharnessreport.js'></script>
<style type="text/css">
#box {
    width: 600px;
    height: 600px;
    touch-action: none;
}
</style>
<div id="box" ></div>

<script type="text/javascript">

var touchMoveCount = 0;
var pointerMoveCount = 0;
var box = document.getElementById("box");
var targetRect = box.getBoundingClientRect();
var offset = 50;
var x = targetRect.left + offset;
var y = targetRect.top + offset;

function validTouchMoveResult(event) {
    touchMoveCount++;
    testTouchMove.step(function () {
        assert_equals(event.target.id, "box");
    });
}

function validPointerMoveResult(event) {
    pointerMoveCount++;
    testTouchMove.step(function () {
        assert_equals(event.target.id, "box");
        assert_equals(event.pointerType, "touch");
    });
}

function callbackValidMoveCount() {
    testTouchMove.step(function () {
        assert_equals(touchMoveCount, 2);
        assert_equals(pointerMoveCount, 3);
    });
    testTouchMove.done();
}

function testMultiPointerMoveSuppressionInSlopRegion() {
    if (window.chrome && chrome.gpuBenchmarking) {
        var pointerActions = 
            [{source: "touch",
              actions: [
                { name: "pointerDown", x: x, y: y },
                { name: "pointerMove", x: x, y: y + 1 },
                { name: "pause" },
                { name: "pause" },
                { name: "pause" },
                { name: "pointerMove", x: x, y: y + 2 },
                { name: "pointerUp" }]},
             {source: "touch",
              actions: [
                { name: "pause" },
                { name: "pause" },
                { name: "pointerDown", x: x, y: y },
                { name: "pointerMove", x: x, y: y + 1 },
                { name: "pointerUp"}]}];
        chrome.gpuBenchmarking.pointerActionSequence(pointerActions, callbackValidMoveCount);
    }
}

var testTouchMove = async_test('Tests that TouchMoves are not suppressed if a secondary pointer is present during any movement.');
box.addEventListener('touchmove', validTouchMoveResult);
box.addEventListener('pointermove', validPointerMoveResult);
testMultiPointerMoveSuppressionInSlopRegion();

</script>